home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / execd1200.iso / Shareware / Blocks 3 / setup.exe / Source / TITLE.C < prev    next >
Encoding:
C/C++ Source or Header  |  2000-10-06  |  8.6 KB  |  363 lines

  1. #include <allegro.h>
  2. #include <jgmod.h>
  3. #include <blocks3.h>
  4.  
  5. int redraw_flag, title_menu_exit, f_no;
  6.  
  7. void Presents(void)
  8. {
  9.  clear(screen);
  10.  clear(temp);
  11.  
  12.  textprintf_centre(temp, fonts[0].dat, 320, 150, 7, "An Ly");
  13.  textprintf_centre(temp, fonts[0].dat, 320, 200, 7, "Presents");
  14.  
  15.  Transition_In(temp, pallete);
  16.  
  17.  clear_keybuf();
  18.  while(!keypressed());
  19.  
  20.  Transition_Out(temp, pallete);
  21. }
  22.  
  23. void Title(void)
  24. {
  25.  scare_mouse();
  26.  
  27.  clear(screen);
  28. /* set_pallete(black_pallete);
  29.  blit(title_gfx, screen, 0, 0, 0, 0, 640, 480);
  30.  
  31.  text_mode(-1);
  32.  textprintf(screen, font, 600, 468, 7, "v0.5");
  33.  
  34.  fade_in(title_pallete, 5);*/
  35.  
  36.  set_pallete(title_pallete);
  37.  Transition_In(title_gfx, title_pallete);
  38.  
  39.  clear_keybuf();
  40.  while(!keypressed());
  41.  clear_keybuf();
  42.  while(keypressed());
  43.  
  44. }
  45.  
  46. int Title_Menu(void)
  47. {
  48.  BITMAP *temp2 = create_bitmap(200, 300);
  49.  int item, game_menu_exit;
  50.  int i, j;
  51.  
  52. /* for (i = 0; i < 640; i+=2)
  53.  for (j = 0; j < 480; j+=2)
  54.  {
  55.   putpixel(screen, i, j, 0);
  56.   putpixel(screen, i + 1, j + 1, 0);
  57.  }*/
  58.  
  59.  rect(temp2, 0, 0, 199, 299, 0);
  60.  
  61.  title_menu_exit = 0;
  62.  item = 0;
  63.  
  64.  /** Come on Down!! (menu) **/
  65.  
  66.  rectfill(temp2, 1, 1, 198, 298, 7);
  67.  rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  68.  rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  69.  rect(temp2, 10, 10, 189, 20, 0);
  70.  rect(temp2, 10, 279, 189, 289, 0);
  71.  
  72.  rectfill(temp2, 10, item*40 + 35, 190, item*40 + 65, makecol(180, 180, 255));
  73.  text_mode(-1);
  74.  
  75.  textprintf_centre(temp2, fonts[0].dat, 100, 35,  0, "Start");
  76.  textprintf_centre(temp2, fonts[0].dat, 100, 75, 0, "Editor");
  77.  textprintf_centre(temp2, fonts[0].dat, 100, 115, 0, "Options");
  78.  textprintf_centre(temp2, fonts[0].dat, 100, 155, 0, "Music");
  79.  textprintf_centre(temp2, fonts[0].dat, 100, 195, 0, "Logout");
  80.  textprintf_centre(temp2, fonts[0].dat, 100, 235, 0, "Exit");
  81.  
  82.  blit(title_gfx, screen, 520, 10, 520, 10, 120, 10);
  83.  textprintf(screen, font, 520, 11, 7, "%s", login);
  84.  
  85.  for (i = -200; i < 230; i+=10)
  86.  {
  87.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 300);
  88.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  89.   while (time_count < 1);
  90.   time_count = 0;
  91.  }
  92.  
  93.  while(!title_menu_exit)
  94.  {
  95.   rectfill(temp2, 1, 1, 198, 298, 7);
  96.   rectfill(temp2, 10, 10, 189, 20, makecol(128, 128, 128));
  97.   rectfill(temp2, 10, 279, 189, 289, makecol(128, 128, 128));
  98.   rect(temp2, 10, 10, 189, 20, 0);
  99.   rect(temp2, 10, 279, 189, 289, 0);
  100.  
  101.   rectfill(temp2, 10, item*40 + 35, 190, item*40 + 65, makecol(180, 180, 255));
  102.   text_mode(-1);
  103.  
  104.   textprintf_centre(temp2, fonts[0].dat, 100, 35,  0, "Start");
  105.   textprintf_centre(temp2, fonts[0].dat, 100, 75, 0, "Editor");
  106.   textprintf_centre(temp2, fonts[0].dat, 100, 115, 0, "Options");
  107.   textprintf_centre(temp2, fonts[0].dat, 100, 155, 0, "Music");
  108.   textprintf_centre(temp2, fonts[0].dat, 100, 195, 0, "Logout");
  109.   textprintf_centre(temp2, fonts[0].dat, 100, 235, 0, "Exit");
  110.  
  111.   blit(temp2, screen, 0, 0, 220, 100, 200, 300);
  112.  
  113.   while ((!key[KEY_ESC]) && (!key[KEY_UP]) && (!key[KEY_DOWN]) && (!key[KEY_ENTER]));
  114.  
  115.   if (key[KEY_ESC])
  116.   {
  117.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  118.    item = 4;
  119.   }
  120.  
  121.   if (key[KEY_ENTER])
  122.   {
  123.    title_menu_exit = 1;
  124.    play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  125.   }
  126.  
  127.   if (key[KEY_UP]) item--;
  128.   if (key[KEY_DOWN]) item++;
  129.  
  130.   if (item < 0) item = 5;
  131.   if (item > 5) item = 0;
  132.   play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  133.  
  134.   while ((key[KEY_ESC]) || (key[KEY_UP]) || (key[KEY_DOWN]) || (key[KEY_ENTER]));
  135.  }
  136.  
  137.  for (i = 220; i < 650; i+=10)
  138.  {
  139.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 300);
  140.   blit(temp2, screen, 0, 0, i, 100, 200, 300);
  141.   while (time_count < 1);
  142.   time_count = 0;
  143.  }
  144.  
  145.  if (item == 0) return 2;
  146.  if (item == 1) return 1;
  147.  if (item == 2)
  148.  {
  149.   Options_Menu();
  150.   return -1;
  151.  }
  152.  if (item == 3)
  153.  {
  154.   Music_Menu();
  155.   return -1;
  156.  }
  157.  
  158.  if (item == 4)
  159.  {
  160.   Log_In();
  161.   return -1;
  162.  }
  163.  if (item == 5) return 0;
  164. }
  165.  
  166. void Log_In(void)
  167. {
  168.  BITMAP *temp2 = create_bitmap(200, 150);
  169.  int i, j;
  170.  
  171.  rectfill(temp2, 0, 0, 199, 149, 7);
  172.  rect(temp2, 0, 0, 199, 149, 0);
  173.  
  174.  rectfill(temp2, 10, 10, 189, 18, makecol(180, 180, 255));
  175.  rect(temp2, 10, 10, 189, 18, 0);
  176.  
  177.  rectfill(temp2, 10, 131, 189, 139, makecol(180, 180, 255));
  178.  rect(temp2, 10, 131, 189, 139, 0);
  179.  
  180.  text_mode(-1);
  181.  
  182.  play_sample(sfx[SFX_INQUIRY].dat, 255, 128, 1000, 0);
  183.  
  184.  textprintf_centre(temp2, fonts[0].dat, 100, 20, 0, "Log In");
  185.  textprintf_centre(temp2, fonts[0].dat, 100, 70, 0, "_", login);
  186.  
  187.  for (i = 0; i < 13; i++)
  188.  login[i] = 0;
  189.  
  190.  for (i = -200; i < 230; i+=10)
  191.  {
  192.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 150);
  193.   blit(temp2, screen, 0, 0, i, 100, 200, 150);
  194.   while (time_count < 1);
  195.   time_count = 0;
  196.  }
  197.  
  198.  clear_keybuf();
  199.  i = 0;
  200.  
  201.  while ((!key[KEY_ENTER]) || (i == 0))
  202.  {
  203.   while(!keypressed());
  204.  
  205.   j = readkey() & 0xff;
  206.  
  207.   if (((j > 64) && (j < 91)) || ((j > 96) && (j < 123)) && (i < 8))
  208.   {
  209.    login[i] = j;
  210.    i++;
  211.    rectfill(temp2, 10, 70, 189, 120, 7);
  212.    textprintf_centre(temp2, fonts[0].dat, 100, 70, 0, "%s_", login);
  213.    blit(temp2, screen, 0, 0, 220, 100, 200, 150);
  214.    play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  215.   }
  216.   if ((key[KEY_BACKSPACE]) && (i > 0))
  217.   {
  218.    i--;
  219.    login[i] = 0;
  220.    rectfill(temp2, 10, 70, 189, 120, 7);
  221.    textprintf_centre(temp2, fonts[0].dat, 100, 70, 0, "%s_", login);
  222.    blit(temp2, screen, 0, 0, 220, 100, 200, 150);
  223.    play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  224.    while(key[KEY_BACKSPACE]);
  225.   }
  226.  }
  227.  
  228.  play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  229.  
  230.  login[i] = 46;
  231.  login[i + 1] = 76;
  232.  login[i + 2] = 79;
  233.  login[i + 3] = 71;
  234.  
  235.  mkdir(login, 0);
  236.  
  237.  for (i = 200; i < 650; i+=10)
  238.  {
  239.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 150);
  240.   blit(temp2, screen, 0, 0, i, 100, 200, 150);
  241.   while (time_count < 1);
  242.   time_count = 0;
  243.  }
  244.  
  245.  blit(title_gfx, screen, 550, 10, 550, 10, 90, 10);
  246.  textprintf(screen, font, 550, 11, 7, "%s", login);
  247.  
  248.  while(key[KEY_ENTER]);
  249. }
  250.  
  251. void Remember_File_Title(char *fn, int a, int b)
  252. {
  253.  strcpy(dir[f_no].name, get_filename(fn));
  254.  f_no++;
  255. }
  256.  
  257. int Open_Maps_Title(void)
  258. {
  259.  int mx, my;
  260.  int file_sel = 0;
  261.  char fn[20];
  262.  int i, j, k, l;
  263.  PACKFILE *file;
  264.  BITMAP *temp2 = create_bitmap(400, 300);
  265.  
  266.  
  267.  f_no = 0;
  268.  for_each_file("./maps/*.map", NULL, Remember_File_Title, 0);
  269.  
  270.  /** draw File Box **/
  271.  
  272.  rectfill(temp2, 0, 0, 399, 299, 7);
  273.  rect(temp2, 0, 0, 399, 299, 0);
  274.  
  275.  rectfill(temp2, 10, 10, 389, 20, makecol(180, 180, 255));
  276.  rect(temp2, 10, 10, 389, 20, 0);
  277.  
  278.  rectfill(temp2, 10, 279, 389, 289, makecol(180, 180, 255));
  279.  rect(temp2, 10, 279, 389, 289, 0);
  280.  
  281.  textprintf_centre(temp2, fonts[0].dat, 200, 20, 0, "Choose Map");
  282.  
  283.  text_mode(7);
  284.  for (i = 0; i < f_no; i++)
  285.  textprintf(temp2, font, 35 + (i/20)*120, 70 + i%20*10, 0, "%s", dir[i].name);
  286.  
  287.  text_mode(makecol(180, 180, 255));
  288.  textprintf(temp2, font, 35 + (file_sel/20)*120, 70 + file_sel%20*10, 0, "%s", dir[file_sel].name);
  289.  
  290.  for (i = -400; i < 130; i+=10)
  291.  {
  292.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 300);
  293.   blit(temp2, screen, 0, 0, i, 100, 400, 300);
  294.   while (time_count < 1);
  295.   time_count = 0;
  296.  }
  297.  
  298.  while ((!key[KEY_ESC]) && (!key[KEY_ENTER]))
  299.  {
  300.   if ((key[KEY_DOWN]) || (key[KEY_UP]))
  301.   {
  302.    play_sample(sfx[SFX_CLICK].dat, 255, 128, 1000, 0);
  303.    if (key[KEY_DOWN]) file_sel++;
  304.    if (key[KEY_UP]) file_sel--;
  305.  
  306.    if (file_sel < 0) file_sel = f_no - 1;
  307.    if (file_sel > f_no - 1) file_sel = 0;
  308.  
  309.    text_mode(7);
  310.    for (i = 0; i < f_no; i++)
  311.    textprintf(temp2, font, 35 + (i/20)*120, 70 + i%20*10, 0, "%s", dir[i].name);
  312.  
  313.    text_mode(makecol(180, 180, 255));
  314.    textprintf(temp2, font, 35 + (file_sel/20)*120, 70 + file_sel%20*10, 0, "%s", dir[file_sel].name);
  315.  
  316.    blit(temp2, screen, 0, 0, 120, 100, 400, 300);
  317.  
  318.    while ((key[KEY_UP]) || (key[KEY_DOWN]));
  319.   }
  320.  }
  321.  
  322.  play_sample(sfx[SFX_FALL].dat, 255, 128, 1000, 0);
  323.  
  324.  if (key[KEY_ESC]) l = 1;
  325.  else l = 0;
  326.  
  327.  for (i = 120; i < 650; i+=10)
  328.  {
  329.   blit(title_gfx, screen, i - 10, 100, i-10, 100, 10, 300);
  330.   blit(temp2, screen, 0, 0, i, 100, 400, 300);
  331.   while (time_count < 1);
  332.   time_count = 0;
  333.  }
  334.  
  335.  if (l == 1)
  336.  {
  337.   while (key[KEY_ESC]);
  338.   return 0;
  339.  }
  340.  
  341.  strcpy(fn, "./maps/");
  342.  strcat(fn, dir[file_sel].name);
  343.  strcpy(map_save, dir[file_sel].name);
  344.  
  345.  file = pack_fopen(fn, "rp");
  346.  
  347.  for (l = 0; l < 100; l++)
  348.  for (k = 0; k < 2; k++)
  349.  for (j = 0; j < 15; j++)
  350.  for (i = 0; i < 20; i++)
  351.  maps[i][j][k][l] = pack_igetw(file);
  352.  
  353.  for (l = 0; l < 100; l++)
  354.  map_motif[l] = pack_igetw(file);
  355.  
  356.  pack_fclose(file);
  357.  
  358.  while(key[KEY_ENTER]);
  359.  
  360.  return 1;
  361. }
  362.  
  363.